/** layuiAdmin.pro-v1.2.1 LPPL License By http://www.layui.com/admin/ */
;
layui.define(["table", "form"],
function(e) {
    var $ = layui.$,
    i = (layui.$, layui.admin),
    t = layui.view,
    l = layui.table,
    r = layui.form;
    l.render({
        elem: "#LAY-agent-manage",
        url: layui.setter.baseUrl+"agent/index",
        cols: [[{
            type: "checkbox",
            fixed: "left"
        },
        {
            field: "id",
            width: 100,
            title: "编号ID",
            sort: !0
        },
        {
            field: "nickname",
            title: "用户",
            minWidth: 100,
            templet: "#imgTpl"
        },
        {
            field: "mobile",
            title: "手机号"
        },
        {
            field: "createtime",
            title: "注册时间",
            templet: "#timeTpl"
        },
        {
            field: "openid",
            title: "openid"
        },
        {
            field: "district",
            title: "地区",
            templet: "#districtTpl"
        },
        {
            field: "credit1",
            title: "累计充值",
            templet: '<span>￥{{ d.credit1 }}</span>'
        },
        {
            field: "numing",
            title: "已使用次数"
        },
        {
            field: "nums",
            title: "可结算次数",
            templet: '<span>{{ d.nums-d.numing }}</span>'
        },
        {
            field: "num",
            title: "点数"
        },
        {
            field: "endtime",
            title: "过期时间",
            templet: "#endtimeTpl"
        },
        {
            title: "更多",
            width: 270,
            align: "center",
            fixed: "right",
            toolbar: "#table-agent-webuser"
        }]],
        page: !0,
        limit: 10,
        text: {
            none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
        }
    }),
    l.on("tool(LAY-agent-manage)",
    function(e) {
        var l = e.data;
        if("del" === e.event){
            layer.confirm("确定删除吗？",function(i) {
                $.post(
                    layui.setter.baseUrl+'agent/del',
                    {id: l.id},
                    function(ret){
                        var {code,msg,data} = ret;
                        layer.alert(msg);
                        if(code==0){
                            layui.table.reload('LAY-agent-manage');
                        }
                    }
                );
            })
        }
        if("edit" === e.event){
            i.popup({
                title: "编辑代理",
                area: [$(window).width()*0.618+'px', $(window).height()*0.9+'px'],
                id: "LAY-popup-agent-edit",
                success: function(e, i) {
                    t(this.id).render("agent/edit", l);
                }
            })
        }
        if("merch" === e.event){
            i.popup({
                title: "旗下商家",
                area: [$(window).width()*0.618+'px', $(window).height()*0.9+'px'],
                id: "LAY-popup-agent-merch",
                success: function(e, i) {
                    layui.params = l;
                    t(this.id).render("agent/merch");
                }
            })
        }
    }),
    e("agent1", {})
});